<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class REXML::Text - rexml: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="Child.html">REXML::Child</a>
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><span class="include">Comparable</span>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-check">::check</a>
    <li ><a href="#method-c-expand">::expand</a>
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-normalize">::normalize</a>
    <li ><a href="#method-c-read_with_substitution">::read_with_substitution</a>
    <li ><a href="#method-c-unnormalize">::unnormalize</a>
    <li ><a href="#method-i-3C-3C">#&lt;&lt;</a>
    <li ><a href="#method-i-3C-3D-3E">#&lt;=&gt;</a>
    <li ><a href="#method-i-clear_cache">#clear_cache</a>
    <li ><a href="#method-i-clone">#clone</a>
    <li ><a href="#method-i-doctype">#doctype</a>
    <li ><a href="#method-i-empty-3F">#empty?</a>
    <li ><a href="#method-i-indent_text">#indent_text</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-node_type">#node_type</a>
    <li class="calls-super" ><a href="#method-i-parent-3D">#parent=</a>
    <li ><a href="#method-i-to_s">#to_s</a>
    <li ><a href="#method-i-value">#value</a>
    <li ><a href="#method-i-value-3D">#value=</a>
    <li ><a href="#method-i-wrap">#wrap</a>
    <li ><a href="#method-i-write">#write</a>
    <li ><a href="#method-i-write_with_substitution">#write_with_substitution</a>
    <li ><a href="#method-i-xpath">#xpath</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-REXML::Text">
    <h1 id="class-REXML::Text" class="class">
      class REXML::Text
    </h1>

    <section class="description">
    
<p>Represents text nodes in an XML document</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="EREFERENCE">EREFERENCE
          <dd>
          <dt id="NEEDS_A_SECOND_CHECK">NEEDS_A_SECOND_CHECK
          <dd>
          <dt id="NUMERICENTITY">NUMERICENTITY
          <dd>
          <dt id="REFERENCE">REFERENCE
          <dd>
          <dt id="SETUTITSBUS">SETUTITSBUS
          <dd>
          <dt id="SLAICEPS">SLAICEPS
          <dd><p>Characters which are substituted in written strings</p>
          <dt id="SPECIALS">SPECIALS
          <dd><p>The order in which the substitutions occur</p>
          <dt id="SUBSTITUTES">SUBSTITUTES
          <dd>
          <dt id="VALID_CHAR">VALID_CHAR
          <dd>
          <dt id="VALID_XML_CHARS">VALID_XML_CHARS
          <dd>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-raw" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">raw</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>If <code>raw</code> is true, then <a href="../REXML.html"><code>REXML</code></a> leaves the value alone</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-check" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check</span><span
                                class="method-args">(string, pattern, doctype)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>check for illegal characters</p>

                              <div class="method-source-code" id="check-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 131</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Text</span>.<span class="ruby-identifier ruby-title">check</span> <span class="ruby-identifier">string</span>, <span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">doctype</span>

  <span class="ruby-comment"># illegal anywhere</span>
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">string</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-constant">VALID_XML_CHARS</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-constant">String</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-value">:encode</span>
      <span class="ruby-identifier">string</span>.<span class="ruby-identifier">chars</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">case</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">ord</span>
        <span class="ruby-keyword">when</span> <span class="ruby-operator">*</span><span class="ruby-constant">VALID_CHAR</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Illegal character #{c.inspect} in raw string #{string.inspect}&quot;</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">string</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/[\x00-\x7F]|[\x80-\xBF][\xC0-\xF0]*|[\xC0-\xF0]/n</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">case</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-string">&#39;U&#39;</span>)
        <span class="ruby-keyword">when</span> <span class="ruby-operator">*</span><span class="ruby-constant">VALID_CHAR</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Illegal character #{c.inspect} in raw string #{string.inspect}&quot;</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># context sensitive</span>
  <span class="ruby-identifier">string</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">pattern</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-node">$1</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">?;</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Illegal character #{$1.inspect} in raw string #{string.inspect}&quot;</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-node">$1</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?&amp;</span>
      <span class="ruby-keyword">if</span> <span class="ruby-node">$5</span> <span class="ruby-keyword">and</span> <span class="ruby-node">$5</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?#</span>
        <span class="ruby-keyword">case</span> (<span class="ruby-node">$5</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?x</span> <span class="ruby-operator">?</span> <span class="ruby-node">$5</span>[<span class="ruby-value">2</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">to_i</span>(<span class="ruby-value">16</span>) <span class="ruby-operator">:</span> <span class="ruby-node">$5</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">to_i</span>)
        <span class="ruby-keyword">when</span> <span class="ruby-operator">*</span><span class="ruby-constant">VALID_CHAR</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Illegal character #{$1.inspect} in raw string #{string.inspect}&quot;</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-comment"># FIXME: below can&#39;t work but this needs API change.</span>
      <span class="ruby-comment"># elsif @parent and $3 and !SUBSTITUTES.include?($1)</span>
      <span class="ruby-comment">#   if !doctype or !doctype.entities.has_key?($3)</span>
      <span class="ruby-comment">#     raise &quot;Undeclared entity &#39;#{$1}&#39; in raw string \&quot;#{string}\&quot;&quot;</span>
      <span class="ruby-comment">#   end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(arg, respect_whitespace=false, parent=nil, raw=nil, entity_filter=nil, illegal=NEEDS_A_SECOND_CHECK )</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Constructor <code>arg</code> if a String, the content is set to the String.  If a <a href="Text.html"><code>Text</code></a>, the object is shallowly cloned.</p>

<p><code>respect_whitespace</code> (boolean, false) if true, whitespace is respected</p>

<p><code>parent</code> (nil) if this is a <a href="Parent.html"><code>Parent</code></a> object, the parent will be set to this.</p>

<p><code>raw</code> (nil) This argument can be given three values. If true, then the value of used to construct this object is expected to contain no unescaped XML markup, and <a href="../REXML.html"><code>REXML</code></a> will not change the text. If this value is false, the string may contain any characters, and <a href="../REXML.html"><code>REXML</code></a> will escape any and all defined entities whose values are contained in the text.  If this value is nil (the default), then the raw value of the parent will be used as the raw value for this node.  If there is no raw value for the parent, and no value is supplied, the default is false. Use this field if you have entities defined for some text, and you don’t want <a href="../REXML.html"><code>REXML</code></a> to escape that text in output.</p>

<pre class="ruby"><span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;&lt;&amp;&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span> ) <span class="ruby-comment">#-&gt; &quot;&amp;lt;&amp;amp;&quot;</span>
<span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;&amp;lt;&amp;amp;&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span> ) <span class="ruby-comment">#-&gt; &quot;&amp;amp;lt;&amp;amp;amp;&quot;</span>
<span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;&lt;&amp;&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span> )  <span class="ruby-comment">#-&gt; Parse exception</span>
<span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;&amp;lt;&amp;amp;&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span> )  <span class="ruby-comment">#-&gt; &quot;&amp;lt;&amp;amp;&quot;</span>
<span class="ruby-comment"># Assume that the entity &quot;s&quot; is defined to be &quot;sean&quot;</span>
<span class="ruby-comment"># and that the entity    &quot;r&quot; is defined to be &quot;russell&quot;</span>
<span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;sean russell&quot;</span> )          <span class="ruby-comment">#-&gt; &quot;&amp;s; &amp;r;&quot;</span>
<span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;sean russell&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span> ) <span class="ruby-comment">#-&gt; &quot;sean russell&quot;</span>
</pre>

<p><code>entity_filter</code> (nil) This can be an array of entities to match in the supplied text.  This argument is only useful if <code>raw</code> is set to false.</p>

<pre class="ruby"><span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;sean russell&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span>, [<span class="ruby-string">&quot;s&quot;</span>] ) <span class="ruby-comment">#-&gt; &quot;&amp;s; russell&quot;</span>
<span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;sean russell&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span>, [<span class="ruby-string">&quot;s&quot;</span>] ) <span class="ruby-comment">#-&gt; &quot;sean russell&quot;</span>
</pre>

<p>In the last example, the <code>entity_filter</code> argument is ignored.</p>

<p><code>illegal</code> INTERNAL USE ONLY</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  <a href="Child.html#method-c-new"><code>REXML::Child::new</code></a>
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 94</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-identifier">respect_whitespace</span>=<span class="ruby-keyword">false</span>, <span class="ruby-identifier">parent</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">raw</span>=<span class="ruby-keyword">nil</span>,
  <span class="ruby-identifier">entity_filter</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">illegal</span>=<span class="ruby-constant">NEEDS_A_SECOND_CHECK</span> )

  <span class="ruby-ivar">@raw</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@parent</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@entity_filter</span> = <span class="ruby-keyword">nil</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">parent</span>
    <span class="ruby-keyword">super</span>( <span class="ruby-identifier">parent</span> )
    <span class="ruby-ivar">@raw</span> = <span class="ruby-identifier">parent</span>.<span class="ruby-identifier">raw</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">String</span>
    <span class="ruby-ivar">@string</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Text</span>
    <span class="ruby-ivar">@string</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-value">:@string</span>).<span class="ruby-identifier">dup</span>
    <span class="ruby-ivar">@raw</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">raw</span>
    <span class="ruby-ivar">@entity_filter</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-value">:@entity_filter</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Illegal argument of type #{arg.type} for Text constructor (#{arg})&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-ivar">@string</span>.<span class="ruby-identifier">squeeze!</span>(<span class="ruby-string">&quot; \n\t&quot;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">respect_whitespace</span>
  <span class="ruby-ivar">@string</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\r\n?/</span>, <span class="ruby-string">&quot;\n&quot;</span>)
  <span class="ruby-ivar">@raw</span> = <span class="ruby-identifier">raw</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">raw</span>.<span class="ruby-identifier">nil?</span>
  <span class="ruby-ivar">@entity_filter</span> = <span class="ruby-identifier">entity_filter</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">entity_filter</span>
  <span class="ruby-identifier">clear_cache</span>

  <span class="ruby-constant">Text</span>.<span class="ruby-identifier">check</span>(<span class="ruby-ivar">@string</span>, <span class="ruby-identifier">illegal</span>, <span class="ruby-identifier">doctype</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@raw</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Class Methods</h3>
                </header>

                  <div id="method-c-expand" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">expand</span><span
                                class="method-args">(ref, doctype, filter)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="expand-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 407</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Text</span>.<span class="ruby-identifier ruby-title">expand</span>(<span class="ruby-identifier">ref</span>, <span class="ruby-identifier">doctype</span>, <span class="ruby-identifier">filter</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">ref</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?#</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">ref</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?x</span>
      [<span class="ruby-identifier">ref</span>[<span class="ruby-value">3</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">to_i</span>(<span class="ruby-value">16</span>)].<span class="ruby-identifier">pack</span>(<span class="ruby-string">&#39;U*&#39;</span>)
    <span class="ruby-keyword">else</span>
      [<span class="ruby-identifier">ref</span>[<span class="ruby-value">2</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">to_i</span>].<span class="ruby-identifier">pack</span>(<span class="ruby-string">&#39;U*&#39;</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">ref</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;&amp;amp;&#39;</span>
    <span class="ruby-string">&#39;&amp;&#39;</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">filter</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">filter</span>.<span class="ruby-identifier">include?</span>( <span class="ruby-identifier">ref</span>[<span class="ruby-value">1</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>] )
    <span class="ruby-identifier">ref</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">doctype</span>
    <span class="ruby-identifier">doctype</span>.<span class="ruby-identifier">entity</span>( <span class="ruby-identifier">ref</span>[<span class="ruby-value">1</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>] ) <span class="ruby-keyword">or</span> <span class="ruby-identifier">ref</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">entity_value</span> = <span class="ruby-constant">DocType</span><span class="ruby-operator">::</span><span class="ruby-constant">DEFAULT_ENTITIES</span>[ <span class="ruby-identifier">ref</span>[<span class="ruby-value">1</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>] ]
    <span class="ruby-identifier">entity_value</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">entity_value</span>.<span class="ruby-identifier">value</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">ref</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-normalize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">normalize</span><span
                                class="method-args">( input, doctype=nil, entity_filter=nil )</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Escapes all possible entities</p>

                              <div class="method-source-code" id="normalize-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 370</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Text</span><span class="ruby-operator">::</span><span class="ruby-identifier ruby-title">normalize</span>( <span class="ruby-identifier">input</span>, <span class="ruby-identifier">doctype</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">entity_filter</span>=<span class="ruby-keyword">nil</span> )
  <span class="ruby-identifier">copy</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">to_s</span>
  <span class="ruby-comment"># Doing it like this rather than in a loop improves the speed</span>
  <span class="ruby-comment">#copy = copy.gsub( EREFERENCE, &#39;&amp;amp;&#39; )</span>
  <span class="ruby-identifier">copy</span> = <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-string">&quot;&amp;&quot;</span>, <span class="ruby-string">&quot;&amp;amp;&quot;</span> ) <span class="ruby-keyword">if</span> <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;&amp;&quot;</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">doctype</span>
    <span class="ruby-comment"># Replace all ampersands that aren&#39;t part of an entity</span>
    <span class="ruby-identifier">doctype</span>.<span class="ruby-identifier">entities</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entity</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">copy</span> = <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-identifier">entity</span>.<span class="ruby-identifier">value</span>,
        <span class="ruby-node">&quot;&amp;#{entity.name};&quot;</span> ) <span class="ruby-keyword">if</span> <span class="ruby-identifier">entity</span>.<span class="ruby-identifier">value</span> <span class="ruby-keyword">and</span>
          <span class="ruby-keyword">not</span>( <span class="ruby-identifier">entity_filter</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">entity_filter</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">entity</span>.<span class="ruby-identifier">name</span>) )
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-comment"># Replace all ampersands that aren&#39;t part of an entity</span>
    <span class="ruby-constant">DocType</span><span class="ruby-operator">::</span><span class="ruby-constant">DEFAULT_ENTITIES</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entity</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">entity</span>.<span class="ruby-identifier">value</span>)
        <span class="ruby-identifier">copy</span> = <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">entity</span>.<span class="ruby-identifier">value</span>, <span class="ruby-node">&quot;&amp;#{entity.name};&quot;</span> )
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">copy</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-read_with_substitution" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_with_substitution</span><span
                                class="method-args">( input, illegal=nil )</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads text, substituting entities</p>

                              <div class="method-source-code" id="read_with_substitution-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 344</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Text</span><span class="ruby-operator">::</span><span class="ruby-identifier ruby-title">read_with_substitution</span>( <span class="ruby-identifier">input</span>, <span class="ruby-identifier">illegal</span>=<span class="ruby-keyword">nil</span> )
  <span class="ruby-identifier">copy</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">clone</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">copy</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">illegal</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParseException</span>.<span class="ruby-identifier">new</span>( <span class="ruby-node">&quot;malformed text: Illegal character #$&amp; in \&quot;#{copy}\&quot;&quot;</span> )
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">illegal</span>

  <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-regexp">/\r\n?/</span>, <span class="ruby-string">&quot;\n&quot;</span> )
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value">?&amp;</span>
    <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SETUTITSBUS</span>[<span class="ruby-value">0</span>], <span class="ruby-constant">SLAICEPS</span>[<span class="ruby-value">0</span>] )
    <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SETUTITSBUS</span>[<span class="ruby-value">1</span>], <span class="ruby-constant">SLAICEPS</span>[<span class="ruby-value">1</span>] )
    <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SETUTITSBUS</span>[<span class="ruby-value">2</span>], <span class="ruby-constant">SLAICEPS</span>[<span class="ruby-value">2</span>] )
    <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SETUTITSBUS</span>[<span class="ruby-value">3</span>], <span class="ruby-constant">SLAICEPS</span>[<span class="ruby-value">3</span>] )
    <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SETUTITSBUS</span>[<span class="ruby-value">4</span>], <span class="ruby-constant">SLAICEPS</span>[<span class="ruby-value">4</span>] )
    <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-regexp">/&amp;#0*((?:\d+)|(?:x[a-f0-9]+));/</span> ) {
      <span class="ruby-identifier">m</span>=<span class="ruby-node">$1</span>
      <span class="ruby-comment">#m=&#39;0&#39; if m==&#39;&#39;</span>
      <span class="ruby-identifier">m</span> = <span class="ruby-node">&quot;0#{m}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?x</span>
      [<span class="ruby-constant">Integer</span>(<span class="ruby-identifier">m</span>)].<span class="ruby-identifier">pack</span>(<span class="ruby-string">&#39;U*&#39;</span>)
    }
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">copy</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-unnormalize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">unnormalize</span><span
                                class="method-args">( string, doctype=nil, filter=nil, illegal=nil )</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Unescapes all possible entities</p>

                              <div class="method-source-code" id="unnormalize-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 394</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Text</span><span class="ruby-operator">::</span><span class="ruby-identifier ruby-title">unnormalize</span>( <span class="ruby-identifier">string</span>, <span class="ruby-identifier">doctype</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">filter</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">illegal</span>=<span class="ruby-keyword">nil</span> )
  <span class="ruby-identifier">sum</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">string</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp">/\r\n?/</span>, <span class="ruby-string">&quot;\n&quot;</span> ).<span class="ruby-identifier">gsub</span>( <span class="ruby-constant">REFERENCE</span> ) {
    <span class="ruby-identifier">s</span> = <span class="ruby-constant">Text</span>.<span class="ruby-identifier">expand</span>(<span class="ruby-node">$&amp;</span>, <span class="ruby-identifier">doctype</span>, <span class="ruby-identifier">filter</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">sum</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">Security</span>.<span class="ruby-identifier">entity_expansion_text_limit</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;entity expansion has grown too large&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">sum</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">bytesize</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">s</span>
  }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-3C-3C" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">&lt;&lt;</span><span
                                class="method-args">( to_append )</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Appends text to this text node.  The text is appended in the <code>raw</code> mode of this text node.</p>

<p><code>returns</code> the text itself to enable method chain like ‘text &lt;&lt; “XXX” &lt;&lt; “YYY”’.</p>

                              <div class="method-source-code" id="3C-3C-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 194</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">&lt;&lt;</span>( <span class="ruby-identifier">to_append</span> )
  <span class="ruby-ivar">@string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">to_append</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp">/\r\n?/</span>, <span class="ruby-string">&quot;\n&quot;</span> )
  <span class="ruby-identifier">clear_cache</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3C-3D-3E" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">&lt;=&gt;</span><span
                                class="method-args">( other )</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><code>other</code> a String or a <a href="Text.html"><code>Text</code></a> <code>returns</code> the result of (<a href="Text.html#method-i-to_s"><code>to_s</code></a> &lt;=&gt; arg.to_s)</p>

                              <div class="method-source-code" id="3C-3D-3E-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 203</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">&lt;=&gt;</span>( <span class="ruby-identifier">other</span> )
  <span class="ruby-identifier">to_s</span>() <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-clone" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">clone</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="clone-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 184</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">clone</span>
  <span class="ruby-keyword">return</span> <span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-keyword">true</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-doctype" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">doctype</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="doctype-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 207</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">doctype</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@parent</span>
    <span class="ruby-identifier">doc</span> = <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">document</span>
    <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">doctype</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">doc</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-empty-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">empty?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="empty-3F-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 179</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">empty?</span>
  <span class="ruby-ivar">@string</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">==</span><span class="ruby-value">0</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-indent_text" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">indent_text</span><span
                                class="method-args">(string, level=1, style=&quot;\t&quot;, indentfirstline=true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="indent_text-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 278</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">indent_text</span>(<span class="ruby-identifier">string</span>, <span class="ruby-identifier">level</span>=<span class="ruby-value">1</span>, <span class="ruby-identifier">style</span>=<span class="ruby-string">&quot;\t&quot;</span>, <span class="ruby-identifier">indentfirstline</span>=<span class="ruby-keyword">true</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">string</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">level</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
  <span class="ruby-identifier">new_string</span> = <span class="ruby-string">&#39;&#39;</span>
  <span class="ruby-identifier">string</span>.<span class="ruby-identifier">each_line</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">indent_string</span> = <span class="ruby-identifier">style</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">level</span>
    <span class="ruby-identifier">new_line</span> = (<span class="ruby-identifier">indent_string</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">line</span>).<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/[\s]+$/</span>,<span class="ruby-string">&#39;&#39;</span>)
    <span class="ruby-identifier">new_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">new_line</span>
  }
  <span class="ruby-identifier">new_string</span>.<span class="ruby-identifier">strip!</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">indentfirstline</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">new_string</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inspect</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="inspect-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 233</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inspect</span>
  <span class="ruby-ivar">@string</span>.<span class="ruby-identifier">inspect</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-node_type" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">node_type</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="node_type-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 175</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">node_type</span>
  <span class="ruby-value">:text</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-parent-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parent=</span><span
                                class="method-args">(parent)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              
                                <div class="method-calls-super">
                                  Calls superclass method
                                  <a href="Child.html#method-i-parent-3D"><code>REXML::Child#parent=</code></a>
                              </div>

                              <div class="method-source-code" id="parent-3D-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 125</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parent=</span> <span class="ruby-identifier">parent</span>
  <span class="ruby-keyword">super</span>(<span class="ruby-identifier">parent</span>)
  <span class="ruby-constant">Text</span>.<span class="ruby-identifier">check</span>(<span class="ruby-ivar">@string</span>, <span class="ruby-constant">NEEDS_A_SECOND_CHECK</span>, <span class="ruby-identifier">doctype</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@raw</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@parent</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">to_s</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the string value of this text node.  This string is always escaped, meaning that it is a valid XML text node string, and all entities that can be escaped, have been inserted.  This method respects the entity filter set in the constructor.</p>

<pre class="ruby"><span class="ruby-comment"># Assume that the entity &quot;s&quot; is defined to be &quot;sean&quot;, and that the</span>
<span class="ruby-comment"># entity &quot;r&quot; is defined to be &quot;russell&quot;</span>
<span class="ruby-identifier">t</span> = <span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;&lt; &amp; sean russell&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span>, [<span class="ruby-string">&#39;s&#39;</span>] )
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">to_s</span>   <span class="ruby-comment">#-&gt; &quot;&amp;lt; &amp;amp; &amp;s; russell&quot;</span>
<span class="ruby-identifier">t</span> = <span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;&lt; &amp; &amp;s; russell&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span> )
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">to_s</span>   <span class="ruby-comment">#-&gt; &quot;&amp;lt; &amp;amp; &amp;s; russell&quot;</span>
<span class="ruby-identifier">u</span> = <span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;sean russell&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span> )
<span class="ruby-identifier">u</span>.<span class="ruby-identifier">to_s</span>   <span class="ruby-comment">#-&gt; &quot;sean russell&quot;</span>
</pre>

                              <div class="method-source-code" id="to_s-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 228</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_s</span>
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@string</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@raw</span>
  <span class="ruby-ivar">@normalized</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Text</span><span class="ruby-operator">::</span><span class="ruby-identifier">normalize</span>( <span class="ruby-ivar">@string</span>, <span class="ruby-identifier">doctype</span>, <span class="ruby-ivar">@entity_filter</span> )
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-value" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">value</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the string value of this text.  This is the text without entities, as it might be used programmatically, or printed to the console.  This ignores the ‘raw’ attribute setting, and any entity_filter.</p>

<pre class="ruby"><span class="ruby-comment"># Assume that the entity &quot;s&quot; is defined to be &quot;sean&quot;, and that the</span>
<span class="ruby-comment"># entity &quot;r&quot; is defined to be &quot;russell&quot;</span>
<span class="ruby-identifier">t</span> = <span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;&lt; &amp; sean russell&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span>, [<span class="ruby-string">&#39;s&#39;</span>] )
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">value</span>   <span class="ruby-comment">#-&gt; &quot;&lt; &amp; sean russell&quot;</span>
<span class="ruby-identifier">t</span> = <span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;&lt; &amp; &amp;s; russell&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span> )
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">value</span>   <span class="ruby-comment">#-&gt; &quot;&lt; &amp; sean russell&quot;</span>
<span class="ruby-identifier">u</span> = <span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;sean russell&quot;</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span> )
<span class="ruby-identifier">u</span>.<span class="ruby-identifier">value</span>   <span class="ruby-comment">#-&gt; &quot;sean russell&quot;</span>
</pre>

                              <div class="method-source-code" id="value-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 250</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">value</span>
  <span class="ruby-ivar">@unnormalized</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Text</span><span class="ruby-operator">::</span><span class="ruby-identifier">unnormalize</span>( <span class="ruby-ivar">@string</span>, <span class="ruby-identifier">doctype</span> )
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-value-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">value=</span><span
                                class="method-args">( val )</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the contents of this text node.  This expects the text to be unnormalized.  It returns self.</p>

<pre class="ruby"><span class="ruby-identifier">e</span> = <span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>( <span class="ruby-string">&quot;a&quot;</span> )
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">add_text</span>( <span class="ruby-string">&quot;foo&quot;</span> )   <span class="ruby-comment"># &lt;a&gt;foo&lt;/a&gt;</span>
<span class="ruby-identifier">e</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">value</span> = <span class="ruby-string">&quot;bar&quot;</span>    <span class="ruby-comment"># &lt;a&gt;bar&lt;/a&gt;</span>
<span class="ruby-identifier">e</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">value</span> = <span class="ruby-string">&quot;&lt;a&gt;&quot;</span>    <span class="ruby-comment"># &lt;a&gt;&amp;lt;a&amp;gt;&lt;/a&gt;</span>
</pre>

                              <div class="method-source-code" id="value-3D-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 261</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">value=</span>( <span class="ruby-identifier">val</span> )
  <span class="ruby-ivar">@string</span> = <span class="ruby-identifier">val</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp">/\r\n?/</span>, <span class="ruby-string">&quot;\n&quot;</span> )
  <span class="ruby-identifier">clear_cache</span>
  <span class="ruby-ivar">@raw</span> = <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-wrap" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">wrap</span><span
                                class="method-args">(string, width, addnewline=false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="wrap-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 267</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">wrap</span>(<span class="ruby-identifier">string</span>, <span class="ruby-identifier">width</span>, <span class="ruby-identifier">addnewline</span>=<span class="ruby-keyword">false</span>)
  <span class="ruby-comment"># Recursively wrap string at width.</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">string</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">width</span>
  <span class="ruby-identifier">place</span> = <span class="ruby-identifier">string</span>.<span class="ruby-identifier">rindex</span>(<span class="ruby-string">&#39; &#39;</span>, <span class="ruby-identifier">width</span>) <span class="ruby-comment"># Position in string with last &#39; &#39; before cutoff</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">addnewline</span> <span class="ruby-keyword">then</span>
    <span class="ruby-keyword">return</span> <span class="ruby-string">&quot;\n&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">string</span>[<span class="ruby-value">0</span>,<span class="ruby-identifier">place</span>] <span class="ruby-operator">+</span> <span class="ruby-string">&quot;\n&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">wrap</span>(<span class="ruby-identifier">string</span>[<span class="ruby-identifier">place</span><span class="ruby-value">+1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>], <span class="ruby-identifier">width</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">string</span>[<span class="ruby-value">0</span>,<span class="ruby-identifier">place</span>] <span class="ruby-operator">+</span> <span class="ruby-string">&quot;\n&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">wrap</span>(<span class="ruby-identifier">string</span>[<span class="ruby-identifier">place</span><span class="ruby-value">+1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>], <span class="ruby-identifier">width</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write</span><span
                                class="method-args">( writer, indent=-1, transitive=false, ie_hack=false )</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-write-label-DEPRECATED">DEPRECATED<span><a href="#method-i-write-label-DEPRECATED">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>See <a href="Formatters.html"><code>REXML::Formatters</code></a></p>

                              <div class="method-source-code" id="write-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 293</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write</span>( <span class="ruby-identifier">writer</span>, <span class="ruby-identifier">indent</span>=<span class="ruby-value">-1</span>, <span class="ruby-identifier">transitive</span>=<span class="ruby-keyword">false</span>, <span class="ruby-identifier">ie_hack</span>=<span class="ruby-keyword">false</span> )
  <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-node">&quot;#{self.class.name}.write is deprecated.  See REXML::Formatters&quot;</span>, <span class="ruby-value">uplevel:</span> <span class="ruby-value">1</span>)
  <span class="ruby-identifier">formatter</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">indent</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">-1</span>
      <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Formatters</span><span class="ruby-operator">::</span><span class="ruby-constant">Pretty</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">indent</span> )
    <span class="ruby-keyword">else</span>
      <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Formatters</span><span class="ruby-operator">::</span><span class="ruby-constant">Default</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">formatter</span>.<span class="ruby-identifier">write</span>( <span class="ruby-keyword">self</span>, <span class="ruby-identifier">writer</span> )
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_with_substitution" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_with_substitution</span><span
                                class="method-args">(out, input)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes out text, substituting special characters beforehand. <code>out</code> A String, IO, or any other object supporting &lt;&lt;( String ) <code>input</code> the text to substitute and the write out</p>

<pre class="ruby"><span class="ruby-identifier">z</span>=<span class="ruby-identifier">utf8</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-string">&quot;U*&quot;</span>)
<span class="ruby-identifier">ascOut</span>=<span class="ruby-string">&quot;&quot;</span>
<span class="ruby-identifier">z</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">r</span> <span class="ruby-operator">&lt;</span>  <span class="ruby-value">0x100</span>
    <span class="ruby-identifier">ascOut</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">r</span>.<span class="ruby-identifier">chr</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">ascOut</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&quot;&amp;#x%x;&quot;</span>, <span class="ruby-identifier">r</span>))
  <span class="ruby-keyword">end</span>
}
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">ascOut</span>
</pre>

                              <div class="method-source-code" id="write_with_substitution-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 325</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_with_substitution</span> <span class="ruby-identifier">out</span>, <span class="ruby-identifier">input</span>
  <span class="ruby-identifier">copy</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">clone</span>
  <span class="ruby-comment"># Doing it like this rather than in a loop improves the speed</span>
  <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SPECIALS</span>[<span class="ruby-value">0</span>], <span class="ruby-constant">SUBSTITUTES</span>[<span class="ruby-value">0</span>] )
  <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SPECIALS</span>[<span class="ruby-value">1</span>], <span class="ruby-constant">SUBSTITUTES</span>[<span class="ruby-value">1</span>] )
  <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SPECIALS</span>[<span class="ruby-value">2</span>], <span class="ruby-constant">SUBSTITUTES</span>[<span class="ruby-value">2</span>] )
  <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SPECIALS</span>[<span class="ruby-value">3</span>], <span class="ruby-constant">SUBSTITUTES</span>[<span class="ruby-value">3</span>] )
  <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SPECIALS</span>[<span class="ruby-value">4</span>], <span class="ruby-constant">SUBSTITUTES</span>[<span class="ruby-value">4</span>] )
  <span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-constant">SPECIALS</span>[<span class="ruby-value">5</span>], <span class="ruby-constant">SUBSTITUTES</span>[<span class="ruby-value">5</span>] )
  <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">copy</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-xpath" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">xpath</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>FIXME This probably won’t work properly</p>

                              <div class="method-source-code" id="xpath-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 305</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">xpath</span>
  <span class="ruby-identifier">path</span> = <span class="ruby-ivar">@parent</span>.<span class="ruby-identifier">xpath</span>
  <span class="ruby-identifier">path</span> <span class="ruby-operator">+=</span> <span class="ruby-string">&quot;/text()&quot;</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">path</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-clear_cache" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">clear_cache</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="clear_cache-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/text.rb, line 338</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">clear_cache</span>
  <span class="ruby-ivar">@normalized</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@unnormalized</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

